/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package br.ufpe.cin.dmo4.middleware.client;

import br.ufpe.cin.dmo4.middleware.message.JSONMarshaller;
import br.ufpe.cin.dmo4.middleware.message.Marshaller;
import br.ufpe.cin.dmo4.middleware.message.MarshallerImpl;
import br.ufpe.cin.dmo4.middleware.message.RequestMessage;
import br.ufpe.cin.dmo4.middleware.message.ResponseMessage;
import br.ufpe.cin.dmo4.middleware.remotingerrors.RemotingError;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author Danilo
 */
public class Client {
    public static void main(String[] args) throws RemotingError {
        Marshaller marshaller = new MarshallerImpl();
        Requestor requestor = new Requestor("localhost", marshaller);
        
        List<Object> parameters = new ArrayList<>();
        parameters.add(2.0);
        parameters.add(2.0);
        
        RequestMessage request = new RequestMessage(1, true, "calculator", "add", parameters);
        
        ResponseMessage response = requestor.invoke(request);
        
        double result = (Double) response.getBody();
        
        System.out.println(result);
    }
}
